/**
 * 
 */
package xj.toolkit.fsm.util;

import xj.toolkit.fsm.ContextKeyFactory;

/**
 * @author hp
 *
 */
public class CompositeKeyFactory implements ContextKeyFactory {

	private	ContextKeyFactory	first;
	private	ContextKeyFactory	second;
	
	public CompositeKeyFactory(ContextKeyFactory first, ContextKeyFactory second) {
		this.first = first;
		this.second = second;
	}
	
	/* (non-Javadoc)
	 * @see com.skymobi.fsm.ContextKeyFactory#removeKey(java.lang.Object)
	 */
	public void removeKey(Object key) {
		first.removeKey(key);
		second.removeKey(key);
	}

	/* (non-Javadoc)
	 * @see com.skymobi.fsm.ContextKeyFactory#transformToKey(java.lang.Object)
	 */
	public Object transformToKey(Object event) {
		Object key = first.transformToKey(event);
		if ( null != key ) {
			return	key;
		}
		return	second.transformToKey(event);
	}

}
